<extend name="Public/index"/>
<block name="pageStatic">
    <link href="__CSS__/style.css" rel="stylesheet"/>
    <script src="__JS__/jquery-1.10.1.min.js"></script>
    <script src="__JS__/scrolltopcontrol.js"></script>
    <script src="__JS__/navigation.js"></script>
</block>
<block name="pageHeader">
    <include file="Public/header.list" />
</block>
<block name="pageContent">
    <include file="Public/header.cate" />
    <volist name="cateList" id="cate">
        <div class="list-box">
            <ul>
                <volist name="cate.docList" id="vo">
                <li <if condition="$key gt 3">style="display:none;" class="li_more"</if>>
                    <div class="list-pic"><a href="{:U('Article/detail', array('id'=>$vo['id']))}"><img src="{$vo.cover_id|get_cover='path'}"></a></div>
                    <div class="list-con">
                        <h5><a href="{:U('Article/detail', array('id'=>$vo['id']))}">{$vo.title}</a></h5>
                        <p><a href="{:U('Article/detail', array('id'=>$vo['id']))}">{$vo.description}</a></p>
<!--                         <div class="time">{$vo.create_time|time_format} <a href="#">{$vo.source}</a></div> -->
                        <div class="collection"><!-- <a class="tb1" href="javascript:;">215</a> --> <a class="tb2" href="javascript:;" article-id="{$vo.id}">{$vo.bookmark}</a></div>
                    </div>
                </li>
                </volist>
            </ul>
            <div class="button-btn">
                <a href="javascript:;" uri="{:U('Category/lists', array('cateid'=>$cate['id']))}" is_child="{$cate['_child']}">
                    <if condition="count($cate['docList']) gt 3">
                        展示更多
                    <else />
                        {$cate['_child'] ? '进入频道页' : '进入栏目页'}
                    </if>
                </a>
            </div>
        </div>
    </volist>
</div>
</block>
<block name="pageJavascript">
    <script>
        $(".list-box .button-btn a").click(function(){
            var li_more = $(this).parent().parent().find('.li_more');
            // 判断是否为显示状态
            var is_hide = li_more.is(":hidden");
            console.log(is_hide);
            if(li_more.length>0 && is_hide){    // 有隐藏的内容
                $(".list-box .li_more").hide(); // 隐藏所有已展开的列表
                $(".list-box .button-btn a").each(function(){
                    var li_more_hidden = $(this).parent().parent().find('.li_more:hidden');
                    if(li_more_hidden.length>0)
                        $(this).html('展示更多');
                })
                li_more.show();
                if($(this).attr('is_child')){
                    $(this).html('进入频道页');
                }else{
                    $(this).html('进入栏目页');
                }
            }else{
                // li_more.hide();
                // $(this).html('展示更多');
                location.href = $(this).attr('uri')
            }
        })
    </script>
</block>